home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-03 / qbnws102.zip / GRAPHSPK.ZIP / BITON.BAS next >
BASIC Source File  |  1989-12-28  |  2KB  |  44 lines

  1. ' ========================== BITON.BAS ================================
  2. '                         Quick Basic 4.5 
  3. '               Copyright 1989 - Frederick Volking
  4. ' All Rights released to public domain by original author on 12/01/89
  5. '
  6. ' =====================================================================
  7. '
  8. ' This is a function. It tests an integer to determine if a specified
  9. ' BIT, in the integer, is set to 1 or 0. If the bit specified is 1, 
  10. ' then the bit is considered ON and the function will return a TRUE(-1).
  11. ' If the specified bit is 0, then the bit is considered OFF and the
  12. ' function will return a FALSE(0).
  13. '
  14. ' ==================================================================
  15. '  Author:       Frederick Volking
  16. '  Contact:      (415)952-3450 [home]          (415)378-4640 [work]
  17. '  USPO Mail:    425 Larch Avenue  -  South San Francisco, CA 94080
  18. '  EchoMail:     ANY Basic conference (I try to read them all)
  19. '  Library At:   QBCentral BBS - Vancouver Washington (206)892-7500
  20. ' ==================================================================
  21. DEFINT A-Z
  22. FUNCTION BitOn (Which, IntVal)
  23.  
  24.    BitOn = 0
  25.    SELECT CASE Which
  26.       CASE 1: IF (IntVal AND 128) THEN BitOn = (-1)
  27.       CASE 2: IF (IntVal AND 64) THEN BitOn = (-1)
  28.       CASE 3: IF (IntVal AND 32) THEN BitOn = (-1)
  29.       CASE 4: IF (IntVal AND 16) THEN BitOn = (-1)
  30.       CASE 5: IF (IntVal AND 8) THEN BitOn = (-1)
  31.       CASE 6: IF (IntVal AND 4) THEN BitOn = (-1)
  32.       CASE 7: IF (IntVal AND 2) THEN BitOn = (-1)
  33.       CASE 8: IF (IntVal AND 1) THEN BitOn = (-1)
  34.       CASE 9: IF (IntVal AND (-32768)) THEN BitOn = (-1)
  35.       CASE 10: IF (IntVal AND 16384) THEN BitOn = (-1)
  36.       CASE 11: IF (IntVal AND 8192) THEN BitOn = (-1)
  37.       CASE 12: IF (IntVal AND 4096) THEN BitOn = (-1)
  38.       CASE 13: IF (IntVal AND 2048) THEN BitOn = (-1)
  39.       CASE 14: IF (IntVal AND 1024) THEN BitOn = (-1)
  40.       CASE 15: IF (IntVal AND 512) THEN BitOn = (-1)
  41.       CASE 16: IF (IntVal AND 256) THEN BitOn = (-1)
  42.    END SELECT
  43.  
  44. END FUNCTION